
import $api from "@/api/index.js"
import {i18n} from "@/utils/i18n" // 多语言
export default {
	state: {
		configInfo: {
			mainColor:'#ffd426',
			btnColor:'#232426',
			mainColor1:'#ff5e00',
			textColor1:'#ff5e00',
		},
		levelList:[],
		cityList:[],
		currentCity:{}, // 当前选择城市 
	},
	mutations: {
		// 更新配置
		updateConfigState(state, item) {
			let {
				key,
				val
			} = item
			state[key] = val
			uni.setStorageSync(key, val)
		}
	},
	actions: {
		async getConfigInfo({
			commit,
			state
		}, param) {
			let res = await $api.base.getConfigInfo()
			let data = Object.assign(state.configInfo, res.data)
			commit('updateConfigState', {
				key: 'configInfo',
				val: data
			})
			if(res.data.level_list.length > 0){
				commit('updateConfigState', {
					key: 'levelList',
					val: res.data.level_list
				})
			}
		},
		
		// 获取城市列表
		async getCityList({
			commit,
			state
		}, param) {
			let res = await $api.content.getCityList()
			commit('updateConfigState', {
				key: 'cityList',
				val: res.data
			})
		},
		// 获取按钮
	}
}